home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / AdobeExamples / NX_Hello / WorldView.m < prev   
Text File  |  1995-06-12  |  3KB  |  102 lines

  1.  
  2. /*
  3.  * (a)  (C) 1990 by Adobe Systems Incorporated. All rights reserved.
  4.  *
  5.  * (b)  If this Sample Code is distributed as part of the Display PostScript
  6.  *    System Software Development Kit from Adobe Systems Incorporated,
  7.  *    then this copy is designated as Development Software and its use is
  8.  *    subject to the terms of the License Agreement attached to such Kit.
  9.  *
  10.  * (c)  If this Sample Code is distributed independently, then the following
  11.  *    terms apply:
  12.  *
  13.  * (d)  This file may be freely copied and redistributed as long as:
  14.  *    1) Parts (a), (d), (e) and (f) continue to be included in the file,
  15.  *    2) If the file has been modified in any way, a notice of such
  16.  *      modification is conspicuously indicated.
  17.  *
  18.  * (e)  PostScript, Display PostScript, and Adobe are registered trademarks of
  19.  *    Adobe Systems Incorporated.
  20.  * 
  21.  * (f) THE INFORMATION BELOW IS FURNISHED AS IS, IS SUBJECT TO
  22.  *    CHANGE WITHOUT NOTICE, AND SHOULD NOT BE CONSTRUED
  23.  *    AS A COMMITMENT BY ADOBE SYSTEMS INCORPORATED.
  24.  *    ADOBE SYSTEMS INCORPORATED ASSUMES NO RESPONSIBILITY
  25.  *    OR LIABILITY FOR ANY ERRORS OR INACCURACIES, MAKES NO
  26.  *    WARRANTY OF ANY KIND (EXPRESS, IMPLIED OR STATUTORY)
  27.  *    WITH RESPECT TO THIS INFORMATION, AND EXPRESSLY
  28.  *    DISCLAIMS ANY AND ALL WARRANTIES OF MERCHANTABILITY, 
  29.  *    FITNESS FOR PARTICULAR PURPOSES AND NONINFRINGEMENT
  30.  *    OF THIRD PARTY RIGHTS.
  31.  */
  32.  
  33. /*
  34. *    WorldView.m
  35. *    WorldView is a subclass of View.  It simply displays and clears a message in
  36. *    the view. The one lesson this example shows is the modification of
  37. *    "drawSelf::" and the call to "display".  The method, "drawSelf::", should
  38. *    not be called directly. 
  39. *
  40. *    Rather, "display" should be called.  The display message performs
  41. *    some necessary overhead such as bringing the View into focus by
  42. *    constructing a clipping path around its frame rectangle and making its
  43. *    coordinate system the current coordinate system for the application.  The
  44. *    display method then messages drawSelf::.  These steps are repeated for
  45. *    each of the View's subviews. 
  46. *
  47. *    Note:  Any instance variables that need to be initialized before the first display
  48. *    should be done in the "init" or "initFrame:" method.  In this case,
  49. *    drawHello is already a null value at its creation so no initialization
  50. *    has to be performed.
  51. */
  52.  
  53. /*
  54. *    Version:    2.0
  55. *    Author:    Ken Fromm
  56. *    History:
  57. *            03-07-91        Added this comment.
  58. */
  59.  
  60. #import "WorldView.h"
  61. #import <dpsclient/wraps.h>
  62.  
  63. @implementation WorldView
  64.  
  65. - drawHello:sender
  66. {
  67.     drawHello = YES;
  68.     [self display];
  69.  
  70.     return self;
  71. }
  72.  
  73. - clearHello:sender
  74. {
  75.     drawHello = NO;
  76.     [self display];
  77.  
  78.     return self;
  79. }
  80.  
  81. /* 
  82.  * The first two lines clear the view,  The remaider display the
  83.  * message in the view.
  84.  */
  85. - drawSelf:(NXRect *) r: (int) count
  86. {
  87.     PSsetgray (NX_LTGRAY);
  88.     PSrectfill (bounds.origin.x, bounds.origin.y,
  89.         bounds.size.width, bounds.size.height);
  90.  
  91.     if (drawHello)
  92.      {
  93.         PSsetgray (NX_BLACK);
  94.         PSmoveto (50.0, 70.0);
  95.         PSselectfont ("Times-Roman", 40.0);
  96.         PSshow ("Hello World");
  97.     }
  98.     return self;
  99. }
  100. @end
  101.